<?php

namespace App\Http\Controllers\home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

use DB;
class OrderController extends Controller
{
    public function index()
	{
		$list=DB::table('type')->get();
		$config=DB::table('config')->get();
        $num=DB::table('order')->where('uid',session()->get('homeuser')->id)->count();
        $order=DB::table('order')->where('uid',session()->get('homeuser')->id)->get();
        return view('home.user.order',['config'=>$config,'list'=>$list,'order'=>$order,'num'=>$num]);
	}
    public function show($id)
    {
        $list=DB::table('type')->get();
		$config=DB::table('config')->get();
        $order=DB::table('order')->join('address','order.did','=','address.id')->where('order.id',$id)->first();
        return view('home.user.orderdetail',['list'=>$list,'config'=>$config,'order'=>$order]);
    }
    public function update($id)
    {
        $data=array('state'=>4);
        $row=DB::table('order')->where('id',$id)->update($data);
        if ($row>0) {
            return back();
        }
    }
}
